package com.hy.study.dto;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @author huyong
 * @date 2024 年 01 月 02 日 17:43: 31
 */
@Component
public class User {
    private static final Logger log = Logger.getLogger(User.class);

    private String id;
    private String userName;
    private String password;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String toString() {
        return "User{" +
                "id='" + id + '\'' +
                ", userName='" + userName + '\'' +
                ", password='" + password + '\'' +
                '}';
    }

    // 使用JSR 250
    @PostConstruct
    public void init() {
        log.info("User 初始化");
    }

    @PreDestroy
    public void destory() {
        log.info("User 被销毁");
    }
}
